import CONSTANT from '@/common/constants.js';
import http from '@/common/http.js';
import Confirm from 'vux/src/components/confirm/index.vue';
import util from '@/common/util.js';

export default {
  name: 'schedule_t',
  components: {Confirm},
  data () {
    return {
      siteId: '',
      // 班级id
      id: '',
      studentId: '',
      studentName: '',
      content: {},
      isDisabled:false,
      signClass:'signUpBtn',
      agree: true,
      show: false
    }
  },
  mounted () {
    this.$router.afterEach((to, from, next) => {
      window.scrollTo(0, 0);
    });
    var _this = this
    var studertids = ''
    _this.siteId = window.sessionStorage.getItem('siteId')
    _this.studentId = window.sessionStorage.getItem('studentId')
    _this.id = window.sessionStorage.getItem('event_id')
    studertids = _this.studentId
    if (studertids == '-1') {
      studertids = ''
    }
    http.post(CONSTANT.SIGNCLASSSCHEDULE, {
      clazzId: _this.id
    }, (res) => {
      //console.log(res)
      _this.content = res
      for (var i = 0;i < res.length;i++) {
        let dateStr = util.dateFormat(res[i].beginTime,true)
        let enddateStr = util.dateFormat(res[i].endTime,true)
        _this.content[i].beginTime = dateStr.substring(0,10)
        _this.content[i].endTime = dateStr.substring(11,16) + '到' + enddateStr.substring(11,16)
        _this.content[i].signIn.signNum = res[i].signIn.signNum + '/' + res[i].signIn.totalNum
      }
    })
  },
  methods: {
    goStuListSchedule (classId,seq,mainId) {
      this.$router.push({path: '/schedule_stu_list',query:{classId:classId,seq:seq,mainId:mainId}})
    },
    comeBack () {
      window.history.go(-1)
    }
  }
}
